package com.qf.collection.iterator;

import java.util.Iterator;
import java.util.UUID;

/**
 * 可以返回x个随机字符串的迭代器
 */
public class RandomStrIterator implements Iterator,Iterable {

    int count = 0;

    int x;

    public RandomStrIterator(int x) {
        this.x = x;
    }

    @Override
    public boolean hasNext() {
        return count<x;
    }

    @Override
    public Object next() {
        String s = UUID.randomUUID().toString();
        count++;
        return s;
    }

    @Override
    public Iterator iterator() {
        return this;
    }
}
